home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Devices / CD-ROM / How to Detect a CD / ReadMe < prev    next >
Encoding:
Text File  |  1995-10-18  |  2.5 KB  |  30 lines  |  [TEXT/ttxt]

  1. You may ask, "What is the best way to determine if a mounted volume or SCSI address is a CD-ROM drive or not?"
  2.  
  3. Unfortunately, there is no good way to determine a CD-ROM drive on a Macintosh. I can make this rather startling statement from years of experience.  Just about every time you think you've come up with a good method for detecting CD-ROM drives, some engineer comes up with a way to defeat your check (without even knowing that they were accomplishing this feat.)
  4.  
  5. As an example, here are some of the approaches you can take.
  6.  
  7. 1) Look at the drive queue element for a mounted drive and see which driver is pointed to by the dQRefNum.  Look at the driver name.  If it's ".AppleCD" then it's probably a CD-ROM drive.
  8.  
  9. This fails for non-Apple CD-ROM drives which have different driver names.
  10.  
  11. 2) Look at the attributes of the drive in the four bytes preceeding the drive queue entry.  If it's "locked in hardware" and removable then it's a CD-ROM drive.
  12.  
  13. This fails because locked removable hard disks or optical media (or even floppies) have the same attributes.  Some CD-ROM drivers allow you to "write" to a CD-ROM drive (they shadow the file system and write the files to a local hard disk, making the local hard disk appear as if it were part of the CD-ROM drive.)
  14.  
  15. 3) Issue a SCSI request directly to the drive.
  16.  
  17. This fails for some early CD-ROM drives (non-SCSI-2 compliant). Before SCSI-2, there was no CD-ROM device type defined.  Some CD-ROM drives reported back that they were disks instead.  You also have the complication of SCSI Manager 4.3 today, and the possibility of IDE CD-ROM drives in the future.  The IDE Manager has a completely different calling architecture, and I couldn't tell you how to identify IDE CD-ROM drives yet, because I haven't seen any yet.
  18.  
  19. 4) Issue a ReadTOC() call to the driver and see if the result that comes back is reasonable.
  20.  
  21. Although a Control() call with csCode 100 is a "famous" CD-ROM driver call, there is nothing which prevents other drivers from implementing that call.  In practice, few do, but it is entirely possible for a different driver to implement that call with different values in csParam.  This can be disasterous.
  22.  
  23. If I were trying to detect a CD-ROM drive, I'd take a combination of approach 1 and approach 4.  For each mounted drive, issue a ReadTOC call to the driver for that drive.  If you get back reasonable results, then you're probably talking to a CD-ROM drive.
  24.  
  25. References:
  26.  
  27. DV 22, CD-ROM Driver Calls
  28. Inside Macintosh:Devices, SCSI Manager 4.3 chapter
  29. Developer Note on Quadra 630, IDE Manager
  30.